﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

using ProjectBase.Core;

namespace Survey.Entity.Services
{
    [Serializable]
    public class Translator : Persistent<int>
    {
        #region members
        IList<Phrase> _phrases;
        IDictionary<string, string> _translations;
        #endregion members

        /// <summary>
        ///     The key to be searched in dictionary of phrases using selected language
        /// </summary>
        public virtual string Key { get; set; }

        /// <summary>
        ///     Optinal more precious indicator for searching the key.
        ///     This value allows to distinguish among same keys in the different areas
        ///     (e.g. controllers, business entities)
        /// </summary>
        public virtual string Area { get; set; }

        /// <summary>
        ///     Phrases for sorting and searching
        /// </summary>
        public virtual IList<Phrase> Phrases
        {
            get { return _phrases ?? (_phrases = new List<Phrase>()); }
            set { _phrases = value; }
        }

        /// <summary>
        ///     Translations for localizing
        /// </summary>
        public virtual IDictionary<string, string> Translations
        {
            get { return _translations ?? (_translations = new Dictionary<string, string>()); }
            set { _translations = value; }
        }

        #region override abstract
        public override string ToDisplay()
        {
            return Key + " " + Area;
        }

        protected override string GetDomainObjectSignature()
        {
            return Key + Area;
        }
        #endregion override abstract

        #region Clone
        public override object Clone()
        {
            var entity = base.Clone() as Translator;

            entity.Translations = new Dictionary<string, string>(Translations);
            entity.Phrases = new List<Phrase>();

            return entity;
        }
        #endregion Clone
    }
}